﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

using CsharpTrainer.Model.Entities;
using PostDbNet;

namespace CsharpTrainer.Core.DAL
{
    public class PostContactDao : IDAO<ContactInfo>
    {
        public bool Insert(ContactInfo obj)
        {
            return false;
        }

        public bool Update(ContactInfo obj)
        {
            return false;
        }

        public bool Delete(int id)
        {
            return false;
        }

        public ContactInfo GetSingle(int id)
        {
            PostSqlUtil db = new PostSqlUtil();
            StringBuilder sql = new StringBuilder("select * from contact_info");
            sql.Append(" where contact_id = ").Append(id);
            DataSet ds = db.GetDataSet(sql.ToString());
            ContactInfo contact = null;
            if (ds.Tables[0].Rows.Count > 0)
            {
                contact = new ContactInfo();
                contact.ContactId = Convert.ToInt32(ds.Tables[0].Rows[0]["contact_id"].ToString());
                contact.Title = ds.Tables[0].Rows[0]["title"].ToString();
                contact.FirstName = ds.Tables[0].Rows[0]["first_name"].ToString();
                contact.LastName = ds.Tables[0].Rows[0]["last_name"].ToString();
                contact.Company = ds.Tables[0].Rows[0]["company"].ToString();
            }

            return contact;
        }

        public IList<ContactInfo> GetAll()
        {
            return null;
        }

        public IList<ContactInfo> GetByCriteria(string criteria)
        {
            return null;
        }

        public DataSet GetDsAll()
        {
            return null;
        }

        public DataSet GetDsByCriteria(string criteria)
        {
            return null;
        }
    }
}
